<template>
    <div class="container">
        <div class="search-box">
            <div class="items">
                <span class="item-title">类型：</span>
                <span class="item-list">
                    <a  href="javascript:void(0)" @click="handleSearchClickType('all')" :class="searchData.type_sub_id === 'all' ? 'selected-item' : ''">全部</a>
                    <a href="javascript:void(0)" @click="handleSearchClickType(id)" v-for="(item, id) in typeOption" :key="id" :class="searchData.type_sub_id === '' + id ? 'selected-item' : ''">{{item.cn_name|fieldDecrypt}}</a>
                </span>
            </div>
            <div class="items">
                <span class="item-title">区域：</span>
                <span class="item-list">
                    <a  href="javascript:void(0)" @click="handleSearchClickProvince('all')" :class="searchData.province_id === 'all' ? 'selected-item' : ''">全部</a>
                    <a href="javascript:void(0)" @click="handleSearchClickProvince(id)" v-for="(item, id) in cityOption" :key="id" :class="searchData.province_id === '' + id ? 'selected-item' : ''">{{item.label|fieldDecrypt}}</a>
                </span>
            </div>
        </div>
        <br/>
        <div class="recommend-tourist">
            <div class="item-content">
                <ul class="tab-content-theme">
                    <li  v-for="(_item, _index) in itemData" :key="_index">
                        <router-link :to="'food/detail/' + _item.hstr">
                            <div class="pic_add"><img alt="景点" :src="_item.image_url|fieldDecrypt" data-original-background="none" style="background: none;width: 100%;"></div>
                            <div class="city_name"></div>
                        </router-link>
                        <div class="item-name">
                            <p>{{_item.cn_name|fieldDecrypt}}<span class="right type-name">{{_item.city_name|fieldDecrypt}}</span></p>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
        <el-pagination
                background
                layout="prev, pager, next"
                @current-change="handleCurrentChange"
                :hide-on-single-page="false"
                :page-size="searchData.page_size"
                :total="total">
        </el-pagination>
    </div>
</template>

<script>
    import 'swiper/css/swiper.css'

    import http from "../util/http";
    export default {
        name: "foodList",
        components: {
        },
        data() {
            return {
                itemData : [],
                searchData: {
                    'page_size': 20,
                    'page_index': 1,
                    'type_sub_id' : 'all',
                    'province_id':'all',
                    'city_id':'all',

                },
                cityOption : [],
                typeOption : []
            }
        },
        mounted() {
            this.getDataList();
        },
        methods:{
            getDataList: function () {
                http.post("food/list", this.searchData).then(res => {
                    if (res.success === true) {
                        this.itemData    = res.data.data;
                        this.cityOption     = res.data.city_option;
                        this.typeOption     = res.data.type_option;
                        console.log(this.touristData);
                    }
                });
            },
            handleSearchClickType: function(typeId) {
                this.searchData.type_sub_id = typeId;
                this.getDataList();
            },
            handleSearchClickProvince: function (provinceId) {
                this.searchData.province_id = provinceId;
                this.getDataList();
            },
            handleCurrentChange: function (pageIndex) {
                this.searchData.page_index = pageIndex;
                this.getDataList();
            }
        }

    }
</script>

<style lang="scss">
    @import './../assets/scss/config.scss';
    @import './../assets/scss/reset.scss';
    @import './../assets/scss/mixin.scss';
    .container {
        min-width: 1200px;
        width: 1200px;
        margin: 0 auto;
        position: relative;
        .search-box {
            padding: 5px 10px;
            border-radius: 0;
            position: relative;
            z-index: 1;
            .items {
                line-height: 26px;
                padding: 4px 10px;
                border-bottom: 1px dashed #D8D8D8;
                .item-title {
                    display: inline-block;
                    *display: inline;
                    *zoom: 1;
                    color: #999;
                    margin-right: 15px;
                    vertical-align: top;
                }
                .item-list {
                    width: 1082px;
                    _width: 1078px;
                    display: inline-block;
                    *display: inline;
                    *zoom: 1;
                    a.selected-item {
                        color: #ff6600;
                        font-weight: bold;
                        margin-right: 20px;
                    }

                    a {
                        margin-right: 20px;
                        display: inline-block;
                        *display: inline;
                        *zoom: 1;
                        cursor: pointer;
                        .item-name {
                            border-bottom: 2px solid #2064c8;
                            margin-bottom: 0
                        }
                        &:visited {
                            color: #333333;
                            text-decoration: none;
                            outline: none;
                        }

                    }
                }
            }
        }
    }
    .item-content {
        .tab-content-theme {
            overflow: hidden;
            width: 1220px;
            li {
                float: left;
                width: 293px;
                margin: 0 10px 10px 0;
                overflow: hidden;
                position: relative;
                &:hover {
                    .scale_tour {
                        border-bottom: 2px solid #F66;
                        margin-bottom: 0
                    }
                    a .pic_add img {
                        bottom: 8px;
                        -webkit-transiton: bottom .3s;
                        transition: bottom .3s
                    }
                }
                a {
                    display: block;
                    width: 100%;
                }
                img {
                    display: block;
                    width: 100%;
                    margin-top: -20px;
                    position: relative;
                    bottom: 0;
                    transition: bottom .3s;
                }
                .pic_add {
                    height: 160px;
                    width: 100%;
                    overflow: hidden;
                }
                .city_name {
                    position: absolute;
                    font: 24px/30px Microsoft yahei;
                    color: #fff;
                    top: 124px;
                    left: 0;
                    text-indent: .5em;
                    text-shadow: 1px 1px 7px #000;
                }
                .mask_num {
                    background: rgba(0,0,0,.5) !important;
                    background: #000;
                    filter: alpha(opacity=50);
                    width: 100px;
                    height: 100px;
                    position: absolute;
                    left: 50%;
                    top: 40px;
                    margin: 0 0 0 -40px;
                    color: #fff;
                    border-radius: 50px;
                    text-align: center;
                    font: 18px/24px Microsoft yahei;
                    color: #fce639;
                    display: none;
                    cursor: pointer;
                }
                .item-name {
                    padding: 5px;
                    background: #f7f7f7;
                    border-bottom: 1px solid #ccc;
                    margin-bottom: 1px;
                    p {
                        color: #555;
                        font: 14px/30px Microsoft yahei;
                        .type-name {
                            font-size: 10px;
                            color: #f55;
                        }
                    }
                }
            }
        }
    }
</style>
